package nsu.edu.zsq.common;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/** 
* Description: 配置WebMvcConfigurer(主要用于配置拦截器、视图跳转)<br>
*/

@Configuration
public class MyWebMvcConfig implements WebMvcConfigurer {

    /** 注册拦截器
     * @see org.springframework.web.servlet.config.annotation.WebMvcConfigurer#addInterceptors(org.springframework.web.servlet.config.annotation.InterceptorRegistry)
     **/
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new HttpInterceptor()).addPathPatterns("/**")
            .excludePathPatterns("/css/**", "/js/**", "/lib/**", "/fonts/**", "/images/**");
    }
    
    
    /** 配置视图跳转，不需要在controller类中进行页面跳转请求的处理了<br>
     *  其中addViewController是设置跳转页面的请求，setViewName设置要跳转到的页面
     * @see org.springframework.web.servlet.config.annotation.WebMvcConfigurer#addViewControllers(org.springframework.web.servlet.config.annotation.ViewControllerRegistry)
     **/
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        // 1.登录页
        registry.addViewController("/toLogin").setViewName("login.html");
        
        // 2.管理员模块
        registry.addViewController("/sys/info/toSchoolMsg").setViewName("manager/manager_schoolMsg.html");
        registry.addViewController("/sys/info/toUpdatePas").setViewName("manager/info/updatePas.html");
        registry.addViewController("/sys/toSysLog").setViewName("manager/manager_sysLog.html");
        // 学校信息管理
        registry.addViewController("/sys/school/org/toOrgList").setViewName("manager/school/orgList.html");
        registry.addViewController("/sys/school/org/toAddOrg").setViewName("manager/school/addOrg.html");
        registry.addViewController("/sys/school/major/toMajorList").setViewName("manager/school/major_list.html");
        registry.addViewController("/sys/school/course/toCourseList").setViewName("manager/school/course_list.html");
        registry.addViewController("/sys/school/course/toPublicCourseList").setViewName("manager/school/publicCourse_list.html");
        registry.addViewController("/sys/school/course/toAddPublicCourse").setViewName("manager/school/publicCourse_add.html");
        registry.addViewController("/sys/school/room/toClassroomList").setViewName("manager/school/classroom_list.html");
        // 班级管理
        registry.addViewController("/sys/class/as/toAsClassList").setViewName("manager/class/as_class_list.html");
        registry.addViewController("/sys/class/teach/toTeachClassList").setViewName("manager/class/teach_class_list.html");
        // 学生管理
        registry.addViewController("/sys/student/info/toStudentList").setViewName("manager/student/student_list.html");
        registry.addViewController("/sys/student/course/toStuCourseList").setViewName("manager/student/course/stuCourse_list.html");
        registry.addViewController("/sys/student/score/toStuClassList").setViewName("manager/student/score/stuClass_list.html");
        registry.addViewController("/sys/student/score/toResitStuClassList").setViewName("manager/student/score/resit_stuClass_list.html");
        registry.addViewController("/sys/student/score/toRetakeStuClassList").setViewName("manager/student/score/retake_stuClass_list.html");
        registry.addViewController("/sys/student/reward/toStuRewardList").setViewName("manager/student/reward/reward_student_list.html");
        // 教师管理
        registry.addViewController("/sys/teacher/info/toTeacherList").setViewName("manager/teacher/teacher_list.html");
        registry.addViewController("/sys/teacher/course/toCourseList").setViewName("manager/teacher/course/teaCourse_list.html");
        // 考务管理
        registry.addViewController("/sys/exam/ToExamList").setViewName("manager/exam/exam_list.html");
        registry.addViewController("/sys/resitExam/ToResitExamList").setViewName("manager/exam/resit/resitExam_list.html");
        registry.addViewController("/sys/resitExam/ToResitExam_addCourse").setViewName("manager/exam/resit/resitExam_addCourse.html");
        registry.addViewController("/sys/retakeCourse/ToRetakeCourse_list").setViewName("manager/exam/retake/retakeCourse_list.html");
        // 管理员账号管理
        registry.addViewController("/sys/sysUser/toSysUser_list").setViewName("manager/sysUser/sysUser_list.html");
        registry.addViewController("/sys/sysUser/toSysUser_add").setViewName("manager/sysUser/sysUser_add.html");
                
        registry.addViewController("/sys/toNoAuth").setViewName("manager/noAuth.html");
        
        // 3.教师信息管理模块
		registry.addViewController("/teacher/info/toUpdatePas").setViewName("teacher/info/updatePas.html");
        registry.addViewController("/teacher/course/toRetakeCourse").setViewName("teacher/course/teaCourse_retakeCourse.html");
        registry.addViewController("/teacher/score/toTchCourse_major_list").setViewName("teacher/scoreManager/tchCourse_major_list.html");
        registry.addViewController("/teacher/score/toTchCourse_minor_list").setViewName("teacher/scoreManager/tchCourse_minor_list.html");
        registry.addViewController("/teacher/score/toResit_list").setViewName("teacher/scoreManager/resit_list.html");
        registry.addViewController("/teacher/score/toRetake_list").setViewName("teacher/scoreManager/retake_list.html");
        
        // 3.学生信息管理模块
        registry.addViewController("/student/info/toUpdatePas").setViewName("student/info/updatePas.html");
        registry.addViewController("/student/info/toStuReward_list").setViewName("student/info/student_reward.html");
        registry.addViewController("/student/course/toChooseCourse_list").setViewName("student/course/chooseCourse_list.html");
        registry.addViewController("/student/course/toChooseCourse_result").setViewName("student/course/chooseCourse_result.html");
        registry.addViewController("/student/score/toResitCourse_list").setViewName("student/score/resitCourse_list.html");
        registry.addViewController("/student/score/toRetakeCourse_list").setViewName("student/score/retakeCourse_list.html");
        registry.addViewController("/student/exam/toExam_list").setViewName("student/exam/exam_list.html");
        registry.addViewController("/student/exam/toResitExam_list").setViewName("student/exam/resitExam_list.html");
        
    }
}
